#ifndef ABSTRACTITEMPROXY_H
#define ABSTRACTITEMPROXY_H



#include <ItemModel.h>



#include <QAbstractProxyModel>
#include <QMap>


typedef QPersistentModelIndex SourceIndex;
typedef QPersistentModelIndex ProxyIndex;

typedef QMap<SourceIndex, ProxyIndex> IndexMap;


class AbstractItemProxy : public QAbstractProxyModel
{
    Q_OBJECT

public:

    AbstractItemProxy(QObject *parent = 0);

    virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
    virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;

    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
    virtual QModelIndex parent(const QModelIndex &child) const;

    virtual int rowCount(const QModelIndex &parent) const;

    ItemModel* itemModel() const;
    void setItemModel(ItemModel* sourceModel);


protected slots:

    virtual void remap() = 0;


protected:

    QAbstractItemModel* sourceModel() const;
    virtual void setSourceModel(QAbstractItemModel *sourceModel);

    IndexMap m_indexMap;


};



#endif // ABSTRACTITEMPROXY_H


